<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" import="java.util.*,java.io.*, java.sql.*, dbAccess.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Edit Patient Information</title>
<link rel="stylesheet" type="text/css" href="css_files/style.css" />
<script type="text/javascript">
function changeNumberofDays(code)
{
	var mylist;
	if (code == "1")
	{
		mylist = document.forms["frmSearchByRange"].cmbStartMonth;
	}
	else if (code == "2")
	{
		mylist = document.forms["frmSearchByRange"].cmbEndMonth;
	}
	else
	{
		mylist = document.forms["frmCreateAppt"].cmbMonth;
	}
	var month = mylist.selectedIndex;
	if ((month == 0) || (month == 2) || (month == 4) || (month == 6) || (month == 7) || (month == 9) || (month == 11))
	{
		var days;
		if (code == "1")
		{
			days = document.forms["frmSearchByRange"].cmbStartDate;
		}
		else if (code == "2")
		{
			days = document.forms["frmSearchByRange"].cmbEndDate;
		}
		else
		{
			days = document.forms["frmCreateAppt"].cmbDate;
		}
		days.options.length = 0;
		var i = 1;
		for (i = 1; i <= 31; i++)
		{
			var opt = document.createElement("option");
			days.options.add(opt);
			opt.text = i;
			opt.value = i;
		}
	}
	else if (month == 1)
	{
		var days;
		if (code == "1")
		{
			days = document.forms["frmSearchByRange"].cmbStartDate;
		}
		else if (code == "2")
		{
			days = document.forms["frmSearchByRange"].cmbEndDate;
		}
		else
		{
			days = document.forms["frmCreateAppt"].cmbDate;
		}
		days.options.length = 0;
		var i = 1;
		for (i = 1; i <= 28; i++)
		{
			var opt = document.createElement("option");
			days.options.add(opt);
			opt.text = i;
			opt.value = i;
		}
	}
	else
	{
		var days;
		if (code == "1")
		{
			days = document.forms["frmSearchByRange"].cmbStartDate;
		}
		else if (code == "2")
		{
			days = document.forms["frmSearchByRange"].cmbEndDate;
		}
		else
		{
			days = document.forms["frmSearchByRange"].cmbDate;
		}
		days.options.length = 0;
		var i = 1;
		for (i = 1; i <= 30; i++)
		{
			var opt = document.createElement("option");
			days.options.add(opt);
			opt.text = i;
			opt.value = i;
		}
	}
}
	
</script>
</head>
<body>
<table width="100%" border="1" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="150" height="125" valign="top"><img src="images/caduceus.gif" alt="" name="LogoLeft" width="150" height="125" id="LogoLeft" style="background-color: #0033FF" /></td>
    <td width="692" align="center" valign="middle"><h1 align="center">CADUCEUS HOSPITAL </h1></td>
    <td width="157" valign="top"><img src="images/hospital.jpg" alt="" name="LogoRight" width="150" height="125" id="LogoRight" style="background-color: #0033FF" /></td>
  </tr>
  <tr>
     <td height="19" colspan="2" valign="top">Welcome <%=session.getAttribute("Name")%>&nbsp;<%=new java.util.Date() %></td>
	<td align="right"> 
		<a href="home.jsp" title="Logout">Logout</a>
	</td> 
  </tr>
</table>
<table width="100%" border="1" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="259" valign="top"><p class="style2"><p><strong>Quicklinks</strong></p>
    <p><a href="patient2appt.jsp">View My Appointments</a></p>
    <p><a href="editPatient.jsp">Change my Personal Information</a></p>
    <p><a href="http://www.webmd.com">WebMD</a></p>
    <p><a href="patientHome.jsp">Back to Homepage</a></p>
    <p>&nbsp;</p></td>
    
    <%
    String callerId = request.getParameter("callerId").toString();
    %>
    
    <td width="740" rowspan="2" class="style2", valign="top"><h3 align="left"><span class="style5"><strong>Edit Patient Records</strong></span></h3>
    <form id="frmPatient" name="frmPatient" method="post" action="patientAddSave.jsp?action=update&callerId=<%=callerId %>">
            <%
		Login lgn = new Login();
		ResultSet rs;
		int patientId = 0;
		String firstName = "unknown";
		String lastName = "unknown";
		String SIN = "unknown";
		String emailAddress = "unknown";
		String phoneNumber = "unknown";
		String homeAddress = "unknown";
		String gender = "unknown";
		String dateOfBirth = "unknown";
		int healthCard = 0;
		String password = "unknown";
		
		rs = lgn.getPatientInfo(Integer.parseInt(session.getAttribute("SIN").toString()));
		if (rs != null)
		{
			while (rs.next())
			{
				patientId = Integer.parseInt(session.getAttribute("patientId").toString()); 
				firstName = session.getAttribute("FirstName").toString();
				lastName = session.getAttribute("LastName").toString();
				SIN = session.getAttribute("SIN").toString();
				emailAddress = session.getAttribute("EmailAddress").toString();
				phoneNumber = session.getAttribute("Phone").toString();
				homeAddress = session.getAttribute("HomeAddress").toString();
				gender = session.getAttribute("Gender").toString();
				dateOfBirth = session.getAttribute("DateOfBirth").toString();
				healthCard = Integer.parseInt(session.getAttribute("healthCard").toString());
				password = session.getAttribute("Password").toString();
			}
		}
	%>
    <table width="647">	
		<tr>
			<td width="117"><strong>
			  First Name
			  </strong></td>
		  <td width="518"><input name="fName" type="text" id="fName" value = <%=firstName%> />
		  </td>
		</tr>
				
		<tr>
			<td><strong>
			  Last Name
			</strong></td>
			<td><input name="lName" type="text" id="lName" value = <%=lastName%> /></td>
		</tr>
				
		<tr>
			<td><strong>
			  SIN
			</strong></td>
			<td><input name="SIN" type="text" id="SIN" value = <%=SIN%> /></td>
		</tr>
				
		<tr>
			<td><strong>
			  Email Address
			</strong></td>
			<td><input name="EmailAddress" type="text" id="EmailAddress" value = <%=emailAddress%> /></td>
		</tr>
				
		<tr>
			<td><strong>
			  Phone Number
			</strong></td>
			<td><input name="phoneNumber" type="text" id="phoneNumber" value = <%=phoneNumber%> /></td>
		</tr>
				
		<tr>
			<td><strong>
			  Home Address
			</strong></td>
			<td><input name="HomeAddress" type="text" id="HomeAddress" size = "128" value = <%=homeAddress%> /></td>
		</tr>
		<tr>
		  <td><strong>Password</strong></td>
		  <td><input name="Password" type="text" id="Password" value = <%=password%> /></td>
	    </tr>
				
		<tr>
			<td><strong>
			  Date Of Birth
			</strong></td>
			<td><input name="DateOfBirth" type="text" id="DateOfBirth" value = <%=dateOfBirth%> /></td>
		</tr>
				
		<tr>
			<td><strong>
			  Gender
			</strong></td>
			<td>
			  <input name="gender" type="radio" value="male" checked />
			  Male 
			  <input name="gender" type="radio" value="female" />
			  Female
			</td>
		</tr>
				
		<tr>
			<td>
			<strong>
			  Health Card Number
			</strong>
			</td>
			<td><input type="healthCardNum" name="healthCardNum" value = <%=healthCard%> />
			
	</td>
		</tr>
	</table>
    <p>&nbsp;</p> <p><input type="submit" name="cmdSave" id="cmdSave" value="Save"/>
    </p>
    </form>	
    </td>
  </tr>
  
  <tr>
    <td height="220" valign="top" class="style2"></td>
   </tr>
 </table>
</body>
</html>